package org.nutz.dao.spring.boot.ddl;

import lombok.RequiredArgsConstructor;
import org.nutz.dao.enhance.config.DaoProperties;
import org.nutz.dao.enhance.factory.EnhanceCoreFactory;
import org.nutz.dao.enhance.method.holder.AutoCreateTableHolder;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

/**
 * @author 黄川 huchuc@vip.qq.com
 * 自动建表
 */
@Order(value = 0)
@Component
@RequiredArgsConstructor
public class DefaualtAutoGenerate implements ApplicationRunner {

    private final DaoProperties nutzDaoProperties;
    private final EnhanceCoreFactory enhanceCoreFactory;

    @Override
    public void run(ApplicationArguments args) {
        AutoCreateTableHolder.autoGenerateDdl(enhanceCoreFactory, nutzDaoProperties);
    }
}
